package com.example.administrator.systemfailreport.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.administrator.systemfailreport.R;
import com.example.administrator.systemfailreport.getpicture.util.Res;

public class MainActivity extends Activity implements View.OnClickListener {

    private Button sysErrorBtn;
    private Button misoperationBtn;
    private Button faultRecordBtn;
    private Button reloginBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Res.init(this);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        sysErrorBtn=(Button)findViewById(R.id.syserror);
        misoperationBtn=(Button)findViewById(R.id.errordo);
        faultRecordBtn=(Button)findViewById(R.id.errreport);
        reloginBtn=(Button)findViewById(R.id.relogin);

        sysErrorBtn.setOnClickListener(this);
        misoperationBtn.setOnClickListener(this);
        faultRecordBtn.setOnClickListener(this);
        reloginBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
         int action=v.getId();
        switch (action){
            case R.id.syserror:
                startToActivity(this, SysErrorActivity.class);
                break;
            case R.id.errordo:
                startToActivity(this, MisoperationActivity.class);
                break;
            case R.id.errreport:
                startToActivity(this, FaultRecordActivity.class);
                break;
            case R.id.relogin:
                startToActivity(this, LoginActivity.class);
                break;

        }
    }
    private void startToActivity(Activity a,Class<?> b){
        Intent intent=new Intent(a,b);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }

}
